package com.yc.damai.damaiother.mapper;

import com.yc.damai.entity.DmCategory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 大麦商城-商品分类表-43 Mapper 接口
 * </p>
 *
 * @author lpt
 * @since 2024-09-08
 */
public interface DmCategoryMapper extends BaseMapper<DmCategory> {

    @Select("select * from dm_category where pid is null")
    @Results(id = "rm1",value = {
            @Result(column = "id",property = "id",id = true),
            @Result(column = "pid",property = "pid"),
            @Result(column = "id",property = "dmCategoryList",many = @Many(
                    select = "queryById"
            ))
    })
    List<DmCategory> queryAll();


    @Select("select * from dm_category where pid is not null and pid = #{pid}")
    List<DmCategory> queryById(int pid);
}
